//t线程等待main线程：

public class Demo5 {
    public static void main(String[] args) throws InterruptedException {
        // 获取到 main 的引用
        Thread mainThread = Thread.currentThread();

        Thread t = new Thread(() -> {
            // 让 t 线程阻塞等待 main 线程
            try {
                System.out.println("t 线程等待之前");
                mainThread.join();
                System.out.println("t 线程等待之后");
            } catch (InterruptedException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        });
        t.start();

        // 让 main 线程执行一定的逻辑
        for (int i = 0; i < 10; i++) {
            System.out.println("hello main");
            Thread.sleep(1000);
        }
    }

}
